home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
BBS
/
EZBBSC.ARJ
/
EZBBSC.PRG
< prev
next >
Wrap
Text File
|
1992-02-04
|
58KB
|
2,261 lines
*****************************************************************************
**
** Program Name: EZBBSC.PRG
** Author: John P. Halovanic
** Copyright (c) 1992, SilverWare Inc.
** Last modified: Jan 30, 1992 - 15:10
**
**
** DISCLAIMER
**
** SilverWare Inc. MAKES NO WARRANTIES, express or implied concerning
** this software including, BUT NOT LIMITED TO, implied warranties of
** MERCHANTABILITY and/or FITNESS for a particular purpose. SilverWare
** Inc. Will NOT BE LIABLE for any damages, CONTINGENT or CONSEQUENTIAL,
** from the use of the product material presented by SilverWare Inc..
** REGISTERED USERS OF SilverClip may use ANY or ALL source code from this
** program for your own development purposes. This program is written in
** Clipper 5, utilizing the SilverClip SPCS Library.
**
**
** Description: EZBBSC.PRG is an example of a simple bulletin board system
** for Clipper 5 using the SilverClip SPCS communications
** library. To run the EZBBSC.PRG copy the following files
** to your default directory:
**
** EZBBSC.PRG
** CLOSE.ANS
** OPEN.ANS
** BBSFILES.DBF
** BBSPARMS.DBF
** BBSUSERS.DBF
**
** Compile EZBBSC.PRG with the following command:
**
** CLIPPER EZBBSC /W/N
**
** Create EZBBSC.EXE with the following command:
**
** RTLINK fi ezbbs lib clipper,extend,terminal,slvrclip
**
**
** ANSI Files: CLOSE.ANS
** OPEN.ANS
**
** NOTE: The ANSI Files (CLOSE.ANS and OPEN.ANS) were created
** with the THEDRAW program available from the SilverBullet
** bulletin board program. NOTE: THEDRAW is not a SilverWare
** product.
**
** Databases:
**
** BBSFILES.DBF
**
** Database that contains a list of the files in the upload/
** download directory. One record for each file in the file
** list. NOTE: The download directory is the CURRENT directory.
**
** 1 FFILE Character 12 -- Filename
** 2 FDESC Character 60 -- Description of file
** 3 FSECURITY Numeric 1 -- Security Level
** 4 FSIZE Numeric 10 -- Size of File
**
** BBSPARMS.DBF
**
** Stores the default parameters for the EZ-BBS System. One
** record.
**
** 1 FPORT Numeric 1 -- Port Number to use
** (Default COM1:)
** 2 FBAUD Numeric 6 -- Maximum baud rate
** (Default: 2400 Baud)
** 3 FMODEM Character 50 -- Modem Setup String
** (Default:
** AT Z &C1 &D2 SO=1)
** 4 FCALLS Numeric 9 -- Number of Calls
** 5 FSYSNAME Character 40 -- System Name
** (Default:
** Welcome to EZ-BBS, by SilverWare Inc.)
** 6 FDEFLEVEL Numeric 1 -- Default Security Level
** (Default: 1)
** 7 FDIRECT Logical 1 -- Direct Connect or Modem
** Connection
** (Default: F (MODEM))
**
** BBSUSERS.DBF
**
** Stores information about users that have logged into the
** EZ-BBS System. One record per caller.
**
** 1 FFIRST Character 10 -- First Name of user
** 2 FLAST Character 15 -- Last Name of user
** 3 FPASSWORD Character 10 -- Users password
** 4 FUSERCALL Numeric 8 -- Number of calls
** 5 FUSERLEVEL Numeric 1 -- Users Security Level
**
*****************************************************************************
**********************************************************************
**
** Procs & Fncts: MAIN()
** : SWINITCOM()
** : SWRESETMODEM()
** : SWSHUTDOWN()
** : SWWAITFORCALL()
** : AUTOBAUD()
** : BASED
** : SWLOGIN()
** : SWOPENFILES()
** : SWPRESSKEY()
** : SWMAINMENU()
** : SWLISTFILES()
** : SWLISTUSERS()
** : SWTRANSMENU()
** : SWTRANSFER()
** : SWSTATUS()
** : SWBACKDROP()
** : SWFILESIZE()
** : SWSKIPLINE()
** : SWASAY()
** : SWAPOSCUR()
** : SWACOLOR()
** : SWACLEAR()
** : SWAGET()
** : SWACURUP()
** : SWACURDWN()
** : SWACURRIGHT()
** : SWACURLEFT()
** : SWAERSEOL()
** : SWAERSBOL()
** : SWAERSLINE()
** : SWAERSEOS()
** : SWAERSBOS()
** : SWABOX()
** : SWAPROMPT()
**
** Calls: MAIN()
**
***********************************************************************
#include "slvrclip.ch"
******************************************************************************
* Define all EZ-BBS constants
******************************************************************************
** Foreground Colors
#define SWAFBLACK 30
#define SWAFRED 31
#define SWAFGREEN 32
#define SWAFYELLOW 33
#define SWAFBLUE 34
#define SWAFMAGENTA 35
#define SWAFCYAN 36
#define SWAFWHITE 37
** Background Colors
#define SWABBLACK 40
#define SWABRED 41
#define SWABGREEN 42
#define SWABYELLOW 43
#define SWABBLUE 44
#define SWABMAGENTA 45
#define SWABCYAN 46
#define SWABWHITE 47
** Special Colors
#define SWABLINK 5
#define SWAREVERSE 7
#define SWABOLD 1
#define SWAUNDERLINE 4
#define SWANORMAL 0
#define EZBBSVER "1.00 [Jan 30, 1992]"
******************************************************************************
* Define all EZ-BBS STATICS
******************************************************************************
STATIC nPort, nBaud, cFirst, cLast, cPassword, nUserCall, nDefLevel, nUserLevel, cFr, lDirect, nMaxRows, nMaxCols
******************************************************************************
* Define all EZ-BBS FIELDS
******************************************************************************
FIELD FPORT, FBAUD, FMODEM, FCALLS, FSYSNAME, FDEFLEVEL, FDIRECT
FIELD FFIRST, FLAST, FPASSWORD, FUSERCALL, FUSERLEVEL
FIELD FFILE, FDESC, FSECURITY, FSIZE
***********************************************************************
**
** Function: MAIN()
**
** Called by: BBS.PRG
**
** Calls: SWSETTRANS()
** : SWOPENFILES()
** : SWBITOR()
** : SWBLDATRIB()
** : SWBACKDROP()
** : SWINITCOM()
** : SWRESETMODEM()
** : SWWAITFORCALL()
** : SWLOGIN()
** : SWACLEAR()
** : SWACOLOR()
** : SWABOX()
** : SWASAY()
** : SWAPOSCUR()
** : SWPRESSKEY()
** : SWMAINMENU()
** : SWSTATUS()
** : SWTXASCII()
** : SWSHUTDOWN()
**
***********************************************************************
FUNCTION MAIN()
******************************************************************************
* Define all variables
******************************************************************************
LOCAL getlist && Stop Warning Message
LOCAL nRet,cModemString,nKey,nMaxVal,nFHighLight,nBHighLight,nMessageRow,nMesageCol,cTemp
MEMVAR cRed,cBlue
SET SCOREBOARD OFF
cFr := (CHR(201)+CHR(205)+CHR(187)+CHR(186)+;
CHR(188)+CHR(205)+CHR(200)+CHR(186)+chr(32))
nMaxRows := 22
nMaxCols := 79
****************************************
* Define File Transfer Box Coordinates *
****************************************
nRet := SWSetTrans(7,6)
nRet := SWSetTrans(8,20)
*********************************
* Open All .DBF and Index Files *
*********************************
nRet := SWOpenFiles(SWTRUE)
*******************************
* Define Local Color Settings *
*******************************
if iscolor()
cRed := "w+/r+,w+/rb+,n"
cBlue := "w+/b,gr+/rb+,n"
nRet := SWSetTrans(4,SWBitOr(SWBldAtrib(SWWHITE,SWBLUE),SWINTENSE))
nRet := SWSetTrans(5,SWBitOr(SWBldAtrib(SWWHITE,SWBLUE),SWINTENSE))
nRet := SWSetTrans(6,SWBldAtrib(SWBLUE,SWCYAN))
else
cRed := "w/n,n/w,n"
cBlue := "w+/n,n/w+,n"
endif
****************
* Setup Screen *
****************
clear
select BBSPARMS
go 1
set color to &cBlue
clear
@0,0 to 7,79 double
set color to &cRed
@0,2 say " Configuration Information "
set color to &cBlue
nPort := FPORT+1
cTemp := "Y"
@2,2 say "COM Port (1234) : " get nPort
@3,2 say "Max Baud Rate : " get FBAUD
@4,2 say "Modem String : " get FMODEM
@5,2 say "Modem CONNECT (Y/N) : " get cTemp
read
if upper(cTemp) == "Y"
replace FDIRECT with SWFALSE
else
replace FDIRECT with SWTRUE
endif
replace FPORT with nPort-1
clear
*******************************
* Initialize Params Variables *
*******************************
select BBSPARMS
nPort := FPORT
nBaud := FBAUD
cModemString := FMODEM
nDefLevel := FDEFLEVEL
lDirect := FDIRECT
*************************
* Local Backdrop Screen *
*************************
nRet := SWBackDrop()
*****************
* Open COM Port *
*****************
nRet := SWInitCom(nPort,nBaud)
if nRet != SWCSUCCESSFUL
nRet := SWStatus("Unable To Open COM Port, Error: "+SWErrToTxt(nRet,0))
nRet := inkey(3)
@17,0 say ""
quit
endif
*********************
* Main Body Of Loop *
*********************
do while lastkey() != 27
nKey := inkey()
nRet := SWResetModem(nPort,cModemString) && Reset Modem
nRet := SWWaitForCall(nPort) && Wait For A Call
if nRet != -1
nRet := SWLogIn(nPort) && Get User Login
endif
if nRet > 0
nUserCall := FUSERCALL
nUserLevel := FUSERLEVEL
**********************************
* Display Local User Information *
**********************************
@1,14 say trim(cFirst)+" "+trim(cLast)
@2,14 say trim(cPassword)
@3,14 say alltrim(str(nUserCall,8,0))
@4,14 say str(nUserLevel,1,0)
*************************
* Send Out User Welcome *
*************************
nRet := SWStatus("Sending Welcome Message...")
select BBSPARMS
replace FCALLS with FCALLS+1
@4,69 say alltrim(str(FCALLS,9,0))
nRet := SWAClear(nPort)
nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
nRet := SWABox(nPort, 3, 2, 17, 65, cFr)
nRet := SWASay(nPort,nMaxRows-2,1,replicate(chr(205),nMaxCols))
nRet := SWASay(nPort,nMaxRows,1,replicate(chr(205),nMaxCols))
nRet := SWAColor(nPort,SWAFWHITE,SWABRED)
nRet := SWASay(nPort,3,4," "+trim(FSYSNAME)+" ")
nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
nRet := SWASay(nPort,5,4,"Welcome "+trim(cFirst)+" "+cLast)
nRet := SWASay(nPort,6,4,"You Are Caller Number "+alltrim(str(FCALLS,8,0)))
nRet := SWASay(nPort,7,4,"You Have Called "+alltrim(str(nUserCall,8,0))+" Times...")
nRet := SWASay(nPort,8,4,"You Security Level Is ("+str(nUserLevele,1,0)+")")
nRet := SWASay(nPort,10,4,"EZ-BBS Version "+EZBBSVER)
nRet := SWASay(nPort,11,4,SWAsyncVer(1))
nRet := SWASay(nPort,12,4,version())
nRet := SWASay(nPort,13,4,"EZ-BBS in written in Clipper 5 and SilverClip (SPCS)")
nRet := SWASay(nPort,14,4,"To receive more information on SilverClip (SPCS)")
nRet := SWASay(nPort,15,4,"Call SilverWare Inc. at (214) 247-0131 ")
nRet := SWAPosCur(nPort,nMaxRows-2,1)
nRet := SWPressKey(nPort)
**********************
* Main Menu Function *
**********************
nRet := SWMainMenu(nPort)
****************************
* Send Out Closing Screen *
****************************
if nRet == 5
if file("CLOSE.ANS")
nRet := SWStatus("Sending Closing Screen")
nRet := SWTXASCII(nPort,"CLOSE.ANS",SWFALSE)
nRet := SWPressKey(nPort)
else
nRet := SWStatus("File CLOSE.ANS Does Not Exist...")
nRet := inkey(1)
endif
endif
endif
enddo
****************************************
* Close Down COM Ports And Exit To DOS *
****************************************
nRet := SWShutDown(nPort)
@17,0 say ""
RETURN(0)
***********************************************************************
**
** Function: SWINITCOM()
**
** Called by: MAIN()
**
** Calls: SWSTATUS()
** : SWOPENCOM()
** : SWSETUART()
**
**
** This function opens the COM port and set the initial baud rate.
**
** nPort = COM port to open.
** nBaud = Initial baud rate to set.
**
**
***********************************************************************
FUNCTION SWInitCom(nPort,nBaud)
LOCAL nRet
nRet := 0
nRet := SWStatus("Opening COM Port: "+str(nPort+1,1,0))
if !SWIsMCA() .and. nPort > 1
nRet := SWSetComm(0,nPort,iif(nPort==2,1000,744))
nRet := SWSetComm(1,nPort,iif(nPort==2,IRQ4,IRQ3))
endif
nRet := SWOpenCom(nPort, 4000, 4000, 0)
if nRet == SWCSUCCESSFUL
nRet := SWSetUart(nPort,nBaud,0,8,1)
endif
RETURN(nRet)
***********************************************************************
**
** Function: SWRESETMODEM()
**
** Called by: MAIN()
**
** Calls: SWSTATUS()
** : SWSETUART()
** : SWMESCAPE()
** : SWMHOOK()
** : SWMTXCMD()
**
** This function will reset the modem to a known state on start-up
** and after every call.
**
** nPort = COM port to use.
** cModemString = Mode setup string in BBSPARMS.DBF.
**
***********************************************************************
FUNCTION SWResetModem(nPort,cModemString)
LOCAL nRet
select BBSPARMS
go top
nBaud := FBAUD
nRet := 0
nRet := SWStatus("Re-setting Modem...")
nRet := SWMEscape(nPort)
nRet := SWWait(18)
nRet := SWMHook(nPort,"0")
nRet := SWWait(18)
nRet := SWSetUart(nPort,nBaud,0,8,1)
nRet := SWMTXCmd(nPort,trim(cModemString))
@3,69 say alltrim(str(nBaud,6,0))
RETURN(0)
***********************************************************************
**
** Function: SWSHUTDOWN()
**
** Called by: MAIN()
**
** Calls: SWSTATUS()
** : SWMESCAPE()
** : SWMHOOK()
** : SWMAUTOANS()
** : SWCLOSECOM()
**
** This function is the shutdown function that closes the COM port,
** closes all open files and exits to DOS.
**
** nPort = COM port in use.
**
**
***********************************************************************
FUNCTION SWShutDown(nPort)
LOCAL nRet
nRet := 0
nRet := SWStatus("Turnning Off Auto-Answer...")
nRet := SWMEscape(nPort)
nRet := SWMHook(nPort,"0")
nRet := SWMAutoAns(nPort,"0")
close databases
close all
nRet := SWStatus("System Returning To DOS...")
nRet := SWCloseCom(nPort, 0)
RETURN(0)
***********************************************************************
**
** Function: SWWAITFORCALL()
**
** Called by: MAIN()
**
** Calls: SWSTATUS()
** : SWGETCD()
** : AUTOBAUD()
**
** This function monitors the modem line for an incomming call.
** When a call is received, it will answer the call and check
** the callers baud rate.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWWaitForCall(nPort)
LOCAL nRet, nKey
nRet := SWStatus("Waiting For Call...")
nRet := -1
do while lastkey() != 27
nKey := inkey()
if SWGetCD(nPort)
if !lDirect
nRet := SWSRTSCTSF(nPort,SWTRUE)
nRet := AutoBaud(nPort, 20, SWTRUE)
else
nRet := nBaud
endif
@3,69 say alltrim(str(nRet,6,0))
nRet := SWStatus("Call CONNECTed At "+alltrim(str(nRet,6,0)))
nRet := 0
exit
endif
enddo
RETURN(nRet)
***********************************************************************
**
** Function: AUTOBAUD()
**
** Called by: SWWAITFORCALL()
**
** Calls: SWGETSEC()
** : SWRXEMPTY()
** : SWMGETRESP()
** : SWSETBAUD()
**
**
**
** This function is designed to be called after the modem (in auto-answer)
** answers the phone or dialing the phone to CONNECT to another mode. When
** two modem CONNECT, they may negotiate a baud rate and drop from your
** current UART baud rate setting to a lower baud rate. This function will
** read the modem response in VERBOSE mode or NON-VERBOSE mode for the
** CONNECT baud rate. The function will optionally call the SWSetBaud()
** function based on the (lSetBaudRate) parameter. The function returns
** the detected baud rate.
**
** nPort = Port vale for the open COM port.
** nMaxTime = Number od seconds to wait for a response.
** lSetBaudRate = Optional setting of the baud rate.
**
**
***********************************************************************
FUNCTION AutoBaud(nPort, nMaxTime, lSetBaudRate)
LOCAL cResponseString, nReturnCode, nBaud, lBaudDetected
nMaxTime := SWGetSec() + nMaxTime
nBaud := SWCTIMEDOUT
lBaudDetected := SWFALSE
cResponseString := ""
do while SWTRUE
if SWGetSec() > nMaxTime && Timer check
nBaud := SWCTIMEDOUT
exit
endif
if !SWGetCD(nPort)
nBaud := SWCNOCARRIER
exit
endif
if !SWRXEmpty(nPort)
nReturnCode := SWMGetResp(nPort,@cResponseString,2)
***** Check VERBOSE and NON-VERBOSE return strings *****
do case
case cResponseString == "CONNECT" .or. cResponseString == "1"
nBaud := 300
lBaudDetected := SWTRUE
case cResponseString == "CONNECT 1200" .or. cResponseString == "5"
nBaud := 1200
lBaudDetected := SWTRUE
case cResponseString == "CONNECT 2400" .or. cResponseString == "10"
nBaud := 2400
lBaudDetected := SWTRUE
case cResponseString == "CONNECT 4800" .or. cResponseString == "11"
nBaud := 4800
lBaudDetected := SWTRUE
case cResponseString == "CONNECT 9600" .or. cResponseString == "12"
nBaud := 9600
lBaudDetected := SWTRUE
case cResponseString == "CONNECT 19200" .or. cResponseString == "14"
nBaud := 19200
lBaudDetected := SWTRUE
endcase
***** Set optional baud rate *****
if lBaudDetected == SWTRUE
if lSetBaudRate == SWTRUE
nReturnCode := SWSetBaud(nPort,nBaud)
nReturnCode := SWTXChar(nPort,13)
endif
exit
endif
endif
enddo
RETURN(nBaud)
***********************************************************************
**
** Function: SWLOGIN()
**
** Called by: MAIN()
**
** Calls: SWSTATUS()
** : SWACLEAR()
** : SWTXASCII()
** : SWFLUSHRX()
** : SWAPOSCUR()
** : SWAERSLINE()
** : SWASAY()
** : SWAGET()
**
** Indexes: USER.NDX
**
** This function prompts the user for login information.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWLogIn(nPort)
LOCAL nTrys, lOK, nRet, cSeekVar, cYN
cFirst := ""
cLast := ""
cPassWord := ""
nTrys := 0
lOK := SWFALSE
nRet := 0
cSeekVar := ""
cYN := "F"
nRet := inkey(1)
nRet := SWFlushRX(nPort)
nRet := SWStatus("Waiting For Remote CARRIER...")
nRet := inkey(10)
nRet := SWStatus("Sending Open Screen...")
nRet := SWAClear(nPort)
if file("OPEN.ANS")
nRet := SWTXASCII(nPort,"OPEN.ANS",SWFALSE)
else
nRet := SWStatus("File OPEN.ANS Does Not Exist...")
endif
nRet := inkey(1)
nRet := SWStatus("Waiting For User Login...")
for nTrys := 1 to 3
nRet := SWFlushRX(nPort)
nRet := SWAPosCur(nPort,21,1)
nRet := SWAErsLine(nPort)
nRet := SWASay(nPort,21,1,"Enter First Name:")
nRet := SWAGet(nPort,21,19,@cFirst,10,60,SWTRUE)
if nRet == SWCLOCALABORT
nTrys := 4
loop
endif
cFirst := upper(cFirst)
nRet := SWAPosCur(nPort,22,1)
nRet := SWAErsLine(nPort)
nRet := SWASay(nPort,22,1,"Enter Last Name :")
nRet := SWAGet(nPort,22,19,@cLast,15,60,SWTRUE)
if nRet == SWCLOCALABORT
nTrys := 4
loop
endif
cLast := upper(cLast)
nRet := SWAPosCur(nPort,23,1)
nRet := SWAErsLine(nPort)
nRet := SWASay(nPort,23,1,"Enter Password :")
nRet := SWAGet(nPort,23,19,@cPassWord,10,60,SWFALSE)
if nRet == SWCLOCALABORT
nTrys := 4
loop
endif
cPassWord := upper(cPassWord)
if (empty(cFirst)) .or. (empty(cLast)) .or. (empty(cPassWord))
loop
endif
select BBSUSERS
set index to user
cSeekVar := substr(cLast+space(15),1,15)+substr(cFirst+space(10),1,10)+substr(cPassWord+space(10),1,10)
seek cSeekVar
if found()
nRet := recno()
replace FUSERCALL with FUSERCALL+1
exit
else
nRet := SWAClear(nPort)
nRet := SWASay(nPort,1,1,"Are You A New User To This System (Y/N) :")
nRet := SWAGet(nPort,1,43,@cYN,2,60,SWTRUE)
if upper(cYN) == "Y"
nRet := SWStatus("New User Logging On...")
cYN := "N"
nRet := SWASay(nPort,4,1,"First Name : "+trim(cFirst))
nRet := SWASay(nPort,5,1,"Last Name : "+trim(cLast))
nRet := SWASay(nPort,6,1,"Password : "+trim(cPassWord))
nRet := SWASay(nPort,8,1,"Is This All Correct (Y/N) :")
nRet := SWAGet(nPort,8,29,@cYN,2,60,SWTRUE)
if upper(cYN) == "Y"
append blank
replace FFIRST with cFirst
replace FLAST with cLast
replace FPASSWORD with cPassWord
replace FUSERCALL with 1
replace FUSERLEVEL with nDefLevel
nRet := recno()
exit
endif
endif
endif
next
RETURN(nRet)
***********************************************************************
**
** Function: SWOPENFILES()
**
** Called by: MAIN()
**
** Calls: SWSTATUS()
**
** Uses: BBSPARMS.DBF Alias: BBSPARMS
** : BBSUSERS.DBF Alias: BBSUSERS
** : BBSFILES.DBF Alias: BBSFILES
**
** Indexes: USER.NDX
** : FILES.NDX
**
** This function open all .DBFs and indexes for the EZ-BBS.
**
** lIndex = SWTRUE -> index all files, SWFALSE -> do not index files.
**
**
***********************************************************************
FUNCTION SWOpenFiles(lIndex)
LOCAL nRet
nRet := SWStatus("Opening All .DBF and Index Files...")
select 1
use BBSPARMS alias BBSPARMS
select 2
use BBSUSERS alias BBSUSERS
select BBSUSERS
go top
if lIndex
index on FLAST+FFIRST+FPASSWORD to user
endif
select 3
use BBSFILES alias BBSFILES
select BBSFILES
go top
if lIndex
index on FFILE to files
endif
RETURN(0)
***********************************************************************
**
** Function: SWPRESSKEY()
**
** Called by: MAIN()
** : SWLISTFILES()
** : SWLISTUSERS()
**
** Calls: SWTXCHAR()
** : SWTXSTRING()
** : SWFLUSHRX()
** : SWWTRXCNT()
**
** This functions sends the message Press Any Key To Continue... to
** the remote user and waits for the key stroke.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWPressKey(nPort)
LOCAL nRet
nRet := SWTXChar(nPort,13)
nRet := SWTXChar(nPort,10)
nRet := SWTXString(nPort,"Press Any Key To Continue...")
nRet := SWFlushRX(nPort)
nRet := SWWtRXCnt(nPort,30*SWSECOND,1)
nRet := SWFlushRX(nPort)
RETURN(0)
***********************************************************************
**
** Function: SWMAINMENU()
**
** Called by: MAIN()
**
** Calls: SWSTATUS()
** : SWACLEAR()
** : SWACOLOR()
** : SWABOX()
** : SWASAY()
** : SWAPROMPT()
** : SWLISTFILES()
** : SWTRANSMENUMENU()
** : SWTRANSFER()
** : SWERRTOTXT()
** : SWLISTUSERS()
**
** This function is the remote main menu of EZ-BBS.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWMainMenu(nPort)
LOCAL aMain := {;
{9,10, "File Listing "," List all files on this system"},;
{10,10,"Download A File"," Download a file to your PC "},;
{11,10,"Upload A File "," Upload a file to this system "},;
{12,10,"User Listing "," List all users on this system"},;
{13,10,"Quit "," Say goodbye and hang up (Log Off)"};
}
LOCAL nRet, nArrayLength, nRow, nCol
nRow := 7
nCol := 8
nArrayLength := len(aMain)
do while SWTRUE
nRet := SWStatus("At Main Menu...")
nRet := SWAClear(nPort)
nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
nRet := SWABox(nPort, nRow, nCol, nRow+8, nCol+18, cFr)
nRet := SWASay(nPort,nMaxRows-2,1,replicate(chr(205),nMaxCols))
nRet := SWASay(nPort,nMaxRows,1,replicate(chr(205),nMaxCols))
nRet := SWAColor(nPort,SWAFWHITE,SWABRED)
nRet := SWASay(nPort,nRow,nCol+2," Main Menu ")
nRet := SWAPrompt(nPort,@aMain,nMaxRows-1,1,SWAFWHITE,SWABBLUE,SWAFWHITE,SWABYELLOW,nArrayLength)
do case
case nRet == 1
nRet := SWListFiles(nPort)
case nRet == 2
nRet := SWTransMenuMenu(nPort) && Sending
if nRet != 6
nRet := SWTransfer(nPort,nRet,0)
nRet := SWStatus("File Transfer Results "+SWErrToTxt(nRet,0))
endif
case nRet == 3
nRet := SWTransMenuMenu(nPort) && Receiving
if nRet != 6
nRet := SWTransfer(nPort,nRet,1)
nRet := SWStatus("File Transfer Results "+SWErrToTxt(nRet,0))
endif
case nRet == 4
nRet := SWListUsers(nPort)
case (nRet == 5) .or. (nRet == SWCNOCARRIER) .or. (nRet == SWCLOCALABORT)
exit
endcase
enddo
RETURN(nRet)
***********************************************************************
**
** Function: SWLISTFILES()
**
** Called by: SWMAINMENU()
**
** Calls: SWSTATUS()
** : SWACLEAR()
** : SWACOLOR()
** : SWASAY()
** : SWAGET()
** : SWSKIPLINE()
** : SWPRESSKEY()
**
** Indexes: FILES.NDX
**
** This function displays to the remote a file listing of files
** contained in the BBSFILES.DBF.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWListFiles(nPort)
LOCAL nRet, nCounter, cHeader, cYN, lSpin
nRet := 0
nCounter := 0
cHeader := "File Size Description"
cYN := "Y"
lSpin := SWTRUE
select BBSFILES
set index to files
go top
nRet := SWStatus("Listing Files...")
do while lSpin
nRet := SWAClear(nPort)
nRet := SWAColor(nPort,SWAFMAGENTA,SWABBLACK)
nRet := SWASay(nPort,1,1,cHeader)
nRet := SWAColor(nPort,SWAFYELLOW,SWABBLACK)
nRet := SWASay(nPort,2,1,replicate("-",nMaxCols))
nCounter := 2
do while SWTRUE
if FSECURITY <= nUserLevel
nCounter := nCounter + 1
nRet := SWAColor(nPort,SWAFCYAN,SWABBLACK)
nRet := SWASay(nPort,nCounter,1,FFILE)
nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
nRet := SWASay(nPort,nCounter,15,str(FSIZE,10,0))
nRet := SWAColor(nPort,SWAFGREEN,SWABBLACK)
nRet := SWASay(nPort,nCounter,27,trim(FDESC))
if nCounter == 22
nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
nRet := SWASay(nPort,24,1,"More (Y/N) ")
nRet := SWAGet(nPort,24,13,@cYN,2,60,SWTRUE)
if upper(cYN) == "N"
lSpin := SWFALSE
exit
else
nRet := SWAClear(nPort)
exit
endif
endif
endif
skip
if eof()
nRet := SWSkipLine(nPort,1)
nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
nRet := SWPressKey(nPort)
lSpin := SWFALSE
exit
endif
enddo
enddo
RETURN(0)
***********************************************************************
**
** Function: SWLISTUSERS()
**
** Called by: SWMAINMENU()
**
** Calls: SWSTATUS()
** : SWACLEAR()
** : SWACOLOR()
** : SWASAY()
** : SWAGET()
** : SWSKIPLINE()
** : SWPRESSKEY()
**
** Indexes: USER.NDX
**
** This function displays to the remote a user listing of users
** contained in the BBSUSERS.DBF.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWListUsers(nPort)
LOCAL nRet, nCounter, cHeader, cBuffer, cYN, lSpin
nRet := 0
nCounter := 0
cHeader := "User Names (Last, First)"
cBuffer := ""
cYN := "Y"
lSpin := SWTRUE
select BBSUSERS
set index to user
go top
nRet := SWStatus("Listing Users...")
do while lSpin
nRet := SWAClear(nPort)
nRet := SWAColor(nPort,SWAFMAGENTA,SWABBLACK)
nRet := SWASay(nPort,1,1,cHeader)
nRet := SWAColor(nPort,SWAFYELLOW,SWABBLACK)
nRet := SWASay(nPort,2,1,replicate("-",40))
nCounter := 2
do while SWTRUE
cBuffer := trim(FLAST)+", "+trim(FFIRST)
nCounter := nCounter + 1
nRet := SWAColor(nPort,SWAFCYAN,SWABBLACK)
nRet := SWASay(nPort,nCounter,1,cBuffer)
if nCounter == 22
nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
nRet := SWASay(nPort,24,1,"More (Y/N) ")
nRet := SWAGet(nPort,24,13,@cYN,2,60,SWTRUE)
if upper(cYN) == "N"
lSpin := SWFALSE
exit
else
nRet := SWAClear(nPort)
exit
endif
endif
skip
if eof()
nRet := SWSkipLine(nPort,1)
nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
nRet := SWPressKey(nPort)
lSpin := SWFALSE
exit
endif
enddo
enddo
RETURN(0)
***********************************************************************
**
** Function: SWTRANSMENU()
**
** Calls: SWSTATUS()
** : SWACOLOR()
** : SWABOX()
** : SWASAY()
** : SWAPROMPT()
**
** This function send the file transfer menu to the remote user. It
** is used for both up-loads and down-loads.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWTransMenu(nPort)
LOCAL aTrans := {;
{10,30,"XMODEM "," CRC/Checksum 128 block"},;
{11,30,"YMODEM "," CRC/Checksum 1024 block"},;
{12,30,"ASCII "," ASCII file transfer"},;
{13,30,"1K-XMODEM "," CRC/Checksum 1024 block"},;
{14,30,"1K-XMODEM-G"," CRC/Checksum 1024 block (No Error Correction)"},;
{15,30,"Cancel "," Return to Main Menu"};
}
LOCAL nRet, nArrayLength, nRow, nCol
nRow := 8
nCol := 28
nArrayLength := len(aTrans)
nRet := SWStatus("File Transfer Menu...")
do while SWTRUE
nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
nRet := SWABox(nPort, nRow, nCol, nRow+9, nCol+14, cFr)
nRet := SWASay(nPort,nMaxRows-2,1,replicate(chr(205),nMaxCols))
nRet := SWASay(nPort,nMaxRows,1,replicate(chr(205),nMaxCols))
nRet := SWAColor(nPort,SWAFWHITE,SWABRED)
nRet := SWASay(nPort,nRow,nCol+2," Protocols ")
nRet := SWAPrompt(nPort,@aTrans,nMaxRows-1,1,SWAFWHITE,SWABBLUE,SWAFWHITE,SWABYELLOW,nArrayLength)
if nRet <= 6
exit
endif
enddo
RETURN(nRet)
***********************************************************************
**
** Function: SWTRANSFER()
**
** Called by: SWMAINMENU()
**
** Calls: SWASAY()
** : SWAGET()
** : SWSTATUS()
** : SWFLUSHRX()
** : SWWTRXCNT()
** : SWTXMODEM()
** : SWTYMODEM()
** : SWTXASCII()
** : SWTXMOD1K()
** : SWTXMOD1KG()
** : SWRXMODEM()
** : SWRYMODEM()
** : SWRXASCII()
** : SWRXMOD1K()
** : SWRXMOD1KG()
** : SWERRTOTXT()
** : SWFILESIZE()
**
** Indexes: FILES.NDX
**
** This function calls the chosen transfer protocol.
**
** nPort = COM port in use.
** nType = Transfer protocol.
** nDirection = Up-load / download.
**
***********************************************************************
FUNCTION SWTransfer(nPort,nType,nDirection)
LOCAL nRet, cFileName, nTemp, cDescription
select BBSFILES
set index to files
go top
cFileName := ""
cDescription := ""
nRet := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
nRet := SWASay(nPort,nMaxRows-1,1," Enter File Name: ")
nRet := SWAGet(nPort,nMaxRows-1,19,@cFileName,13,60,SWTRUE)
cFileName := trim(cFileName)
if cFileName == ""
else
if nDirection == 0
seek cFileName
if !found()
nType := 0
else
if FSECURITY > nUserLevel
nType := 0
endif
endif
else
seek cFileName
if file(cFileName) .or. found()
nType := 0
endif
endif
if nType != 0
nTemp := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
nTemp := SWASay(nPort,nMaxRows-1,1," Begin Your Transfer -> "+trim(cFileName))
endif
if nDirection == 0 && Sending
nRet := SWStatus("Sending File -> "+trim(cFileName))
nRet := SWFlushRX(nPort)
nRet := SWWtRXCnt(nPort,2*SWSECOND,1)
do case
case nType == 0
nRet := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
nRet := SWASay(nPort,nMaxRows-1,1," File "+trim(cFileName)+" Does Not Exist, Please Try Again")
nRet := inkey(2)
nRet := SWCUNABLETOOPENFILE
case nType == 1
nRet := SWTXMODEM(nPort,trim(FFILE))
case nType == 2
nRet := SWTYMODEM(nPort,trim(FFILE))
case nType == 3
nRet := SWTXASCII(nPort,trim(FFILE),SWFALSE)
case nType == 4
nRet := SWTXMOD1K(nPort,trim(FFILE))
case nType == 5
nRet := SWTXMOD1KG(nPort,trim(FFILE))
endcase
else && Receiving
nRet := SWStatus("Receiving File -> "+trim(cFileName))
nRet := inkey(2)
do case
case nType == 0
nRet := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
nRet := SWASay(nPort,1,1,"File "+trim(cFileName)+" Already Exist, Please Change File Name")
nRet := inkey(2)
nRet := SWCUNABLETOOPENFILE
case nType == 1
nRet := SWRXMODEM(nPort,cFileName)
case nType == 2
nRet := SWRYMODEM(nPort,cFileName)
case nType == 3
nRet := SWWtRXCnt(nPort,15*SWSECOND,10)
nRet := SWRXASCII(nPort,cFileName,SWFALSE,5)
if nRet == SWCTIMEDOUT
nRet := SWCSUCCESSFUL
endif
case nType == 4
nRet := SWRXMOD1K(nPort,cFileName)
case nType == 5
nRet := SWRXMOD1KG(nPort,cFileName)
endcase
endif
endif
nTemp := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
nTemp := SWASay(nPort,nMaxRows-1,1," File Transfer response, "+SWErrToTxt(nRet,0))
nTemp := inkey(2)
if nRet == SWCSUCCESSFUL .and. nDirection == 1
nRet := SWStatus("Entering File Description...")
nTemp := SWASay(nPort,nMaxRows-1,1,"Description: ")
nTemp := SWAGet(nPort,nMaxRows-1,16,@cDescription,60,60,SWTRUE)
append blank
replace FFILE with cFileName
replace FDESC with cDescription
replace FSIZE with SWFileSize(cFileName)
replace FSECURITY with 0
endif
RETURN(nRet)
***********************************************************************
**
** Function: SWSTATUS()
**
** Called by: MAIN()
** : SWINITCOM()
** : SWRESETMODEM()
** : SWSHUTDOWN()
** : SWWAITFORCALL()
** : SWLOGIN()
** : SWOPENFILES()
** : SWMAINMENU()
** : SWLISTFILES()
** : SWLISTUSERS()
** : SWTRANSMENU()
** : SWTRANSFER()
**
** This function displays to the local screen the status of a user
** online.
**
** cString = String to display.
**
**
***********************************************************************
FUNCTION SWStatus(cString)
@23,2 say space(77)
@23,2 say alltrim(cString)
RETURN(0)
***********************************************************************
**
** Function: SWBACKDROP()
**
** Called by: MAIN()
**
** This function creates the EZ-BBS local screen.
**
***********************************************************************
FUNCTION SWBackDrop()
LOCAL nCol, getlist
clear
nCol := 2
set color to &cBlue
@0,nCol-2 to 5,50 double
set color to &cRed
@0,nCol say " User Information "
set color to &cBlue
@1,nCol say "Name: "
@2,nCol say "Password: "
@3,nCol say "Calls: "
@4,nCol say "User Level: "
select BBSPARMS
nCol := 55
set color to &cBlue
@0,nCol-2 to 5,79 double
set color to &cRed
@0,nCol say " EZ BBS Online "
set color to &cBlue
@1,nCol say "CONNECT Type: "+iif(lDirect==SWTRUE,"Direct","Modem")
@2,nCol say "COM Port : "+str(FPORT+1,1,0)
@3,nCol say "Baud Rate : "+alltrim(str(FBAUD,6,0))
@4,nCol say "Total Calls : "+alltrim(str(FCALLS,9,0))
nCol := 2
set color to &cBlue
@22,nCol-2 to 24,79 double
set color to &cRed
@22,nCol say " Status Information "
@22,65 say " ESC To Quit "
set color to &cBlue
nCol := 12
set color to &cBlue
@7,nCol-2 to 16,69 double
set color to &cRed
@7,nCol say " Program Information "
set color to &cBlue
@8,nCol say "EZ-BBS Version "+EZBBSVER
@9,nCol say SWAsyncVer(1)
@10,nCol say os()
@11,nCol say version()
@13,nCol say "EZ-BBS in written in Clipper 5 and SilverClip (SPCS)"
@14,nCol say "To receive more information on SilverClip (SPCS)"
@15,nCol say "Call SilverWare Inc. at (214) 247-0131 "
RETURN(0)
***********************************************************************
**
** Function: SWFILESIZE()
**
** Called by: SWTRANSFER()
**
** This function returns the file size of a cFileSpec.
**
** cFileSpec = drive:\path\filename.ext
**
**
***********************************************************************
FUNCTION SWFileSize(cFileSpec)
LOCAL nHandle, nLength, nRet
nHandle := fopen(cFileSpec,0) && Open file read only
nLength := fseek(nHandle,0,2) && Find eof
nRet := fclose(nHandle) && Close file
RETURN(nLength)
***********************************************************************
**
** Function: SWSKIPLINE()
**
** Called by: SWLISTFILES()
** : SWLISTUSERS()
**
** Calls: SWTXCHAR()
**
** This function will move the remote cursor down nLines.
**
** nPort = COM port in use.
** nLines = Number of lines to skip.
**
***********************************************************************
FUNCTION SWSkipLine(nPort,nLines)
LOCAL nCounter, nRet
for nCounter := 1 to nLines
nRet := SWTXChar(nPort,13)
nRet := SWTXChar(nPort,10)
next
RETURN(nLines)
***************************
***************************
***************************
***** ANSI Functions ******
***************************
***************************
***************************
***********************************************************************
**
** Function: SWASAY()
**
** Called by: MAIN()
** : SWLOGIN()
** : SWMAINMENU()
** : SWLISTFILES()
** : SWLISTUSERS()
** : SWTRANSMENU()
** : SWTRANSFER()
** : SWAGET()
** : SWABOX()
** : SWAPROMPT()
**
** Calls: SWAPOSCUR()
** : SWTXBUFFER()
**
***********************************************************************
FUNCTION SWASay(nPort,nRow,nCol,cString)
LOCAL nRet
nRet := 0
nRet := SWAPosCur(nPort,nRow,nCol)
nRet := SWTXBuffer(nPort,cString,len(cString))
RETURN(0)
***********************************************************************
**
** Function: SWAPOSCUR()
**
** Called by: MAIN()
** : SWLOGIN()
** : SWASAY()
** : SWAGET()
** : SWAPROMPT()
**
** Calls: SWTXBUFFER()
**
** This is an ANSI @say function.
**
** nPort = COM port in use.
** nRow = Row position.
** nCol = Column position.
**
***********************************************************************
FUNCTION SWAPosCur(nPort,nRow,nCol)
LOCAL cANSIRowCol, nRet
cANSIRowCol := chr(27)+"["+alltrim(str(nRow,2,0))+";"+alltrim(str(nCol,2,0))+"H"
nRet := SWTXBuffer(nPort,cANSIRowCol,len(cANSIRowCol))
RETURN(0)
***********************************************************************
**
** Function: SWACOLOR()
**
** Called by: MAIN()
** : SWMAINMENU()
** : SWLISTFILES()
** : SWLISTUSERS()
** : SWTRANSMENU()
** : SWACLEAR()
** : SWAPROMPT()
**
** Calls: SWTXBUFFER()
**
** This is an ANSI (set color to) function.
**
** nPort = COM port in use.
** nForeGrnd = Foreground color.
** nBackGrnd = Background color.
**
***********************************************************************
FUNCTION SWAColor(nPort,nForeGrnd,nBackGrnd)
LOCAL cForeGrnd, cBackGrnd, nRet, cColorBuffer
cForeGrnd := alltrim(str(nForeGrnd,2,0))
cBackGrnd := alltrim(str(nBackGrnd,2,0))
cColorBuffer := chr(27)+"["+cForeGrnd+"m"+chr(27)+"["+cBackGrnd+"m"
nRet := SWTXBuffer(nPort,cColorBuffer,len(cColorBuffer))
RETURN(0)
***********************************************************************
**
** Function: SWACLEAR()
**
** Called by: MAIN()
** : SWLOGIN()
** : SWMAINMENU()
** : SWLISTFILES()
** : SWLISTUSERS()
**
** Calls: SWTXBUFFER()
** : SWACOLOR()
**
** This is an ANSI (clear screen) function.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWAClear(nPort)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"[40m"+chr(27)+"[2J"+chr(27)+"[40m"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
nRet := SWAColor(nPort,SWABOLD,SWABBLACK)
RETURN(0)
***********************************************************************
**
** Function: SWAGET()
**
** Called by: SWLOGIN()
** : SWLISTFILES()
** : SWLISTUSERS()
** : SWTRANSFER()
**
** Calls: SWAPOSCUR()
** : SWASAY()
** : SWFLUSHRX()
** : SWRXSTRING()
**
** This is an ANSI (get/read) function.
**
** nPort = COM port in use
** nRow = Row position.
** nCol = Column position.
** cGetString = String variable (pass by ref. @) for get.
** nMaxLength = Data entry length.
** nMaxTime = Time out for entry.
** lRegular = SWTRUE -> echo key strokes, SWFALSE -> echo dots
**
***********************************************************************
FUNCTION SWAGet(nPort,nRow,nCol,cGetString,nMaxLength,nMaxTime,lRegular)
LOCAL nRet
nRet := SWAPosCur(nPort,nRow,nCol)
nRet := SWASay(nPort,nRow,nCol,space(nMaxLength))
nRet := SWAPosCur(nPort,nRow,nCol)
nRet := SWFlushRX(nPort)
nRet := SWRXString(nPort,@cGetString,nMaxLength,13,nMaxTime,.t.,lRegular,46,283)
if nRet == SWCTERMINATORREACHED
cGetString := substr(cGetString,1,len(cGetString)-1)
endif
RETURN(nRet)
***********************************************************************
**
** Function: SWACURUP()
**
** Calls: SWTXBUFFER()
**
** This function move the remote cursor up nLinesUp.
**
** nPort = COM port in use.
** nLinesUp = Number lines to move.
**
***********************************************************************
FUNCTION SWACurUp(nPort,nLinesUp)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"["+alltrim(str(nLinesUp,2,0))+"A"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWACURDWN()
**
** Calls: SWTXBUFFER()
**
** This function move the remote cursor down nLinesDwn.
**
** nPort = COM port in use.
** nLinesDwn = Number lines to move.
**
***********************************************************************
FUNCTION SWACurDwn(nPort,nLinesDwn)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"["+alltrim(str(nLinesDwn,2,0))+"B"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWACURRIGHT()
**
** Calls: SWTXBUFFER()
**
** This function move the remote cursor to the right nColsRight.
**
** nPort = COM port in use.
** nColsRight = Number of columns to move.
**
***********************************************************************
FUNCTION SWACurRight(nPort,nColsRight)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"["+alltrim(str(nColsRight,2,0))+"C"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWACURLEFT()
**
** Calls: SWTXBUFFER()
**
** This function move the remote cursor to the left nColsLeft.
**
** nPort = COM port in use.
** nColsLeft = Number of columns to move.
**
***********************************************************************
FUNCTION SWACurLeft(nPort,nColsLeft)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"["+alltrim(str(nColsLeft,2,0))+"D"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWAERSEOL()
**
** Calls: SWTXBUFFER()
**
** This function will erase from the current cursor position to the
** end of the current line. (row)
**
** nPort = COM port in use.
**
**
***********************************************************************
FUNCTION SWAErsEOL(nPort)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"[0K"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWAERSBOL()
**
** Calls: SWTXBUFFER()
**
** This function will erase from the current cursor position to the
** beginning of the current line. (row)
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWAErsBOL(nPort)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"[1K"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWAERSLINE()
**
** Called by: SWLOGIN()
** : SWAPROMPT()
**
** Calls: SWTXBUFFER()
**
** This function will erase the entire current line.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWAErsLine(nPort)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"[2K"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWAERSEOS()
**
** Calls: SWTXBUFFER()
**
** This function will erase from the current cursor position to the
** end of the screen.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWAErsEOS(nPort)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"[0J"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWAERSBOS()
**
** Calls: SWTXBUFFER()
**
** This function will erase from the current cursor position to the
** beginning of the screen.
**
** nPort = COM port in use.
**
***********************************************************************
FUNCTION SWAErsBOS(nPort)
LOCAL cBuffer, nRet
cBuffer := chr(27)+"[1J"
nRet := SWTXBuffer(nPort,cBuffer,len(cBuffer))
RETURN(nRet)
***********************************************************************
**
** Function: SWABOX()
**
** Called by: MAIN()
** : SWMAINMENU()
** : SWTRANSMENU()
**
** Calls: SWASAY()
**
** This function draws a box on the remote screen.
**
** nPort = COM port in use.
** nRow1 = Upper left row.
** nCol1 = Upper left column.
** nRow2 = Lower right row.
** nCol2 = Lower right column.
** cFrame = Box frame.
**
***********************************************************************
FUNCTION SWABox(nPort, nRow1, nCol1, nRow2, nCol2, cFrame)
LOCAL nLines, nWidth, nLoop, cUL, cUR, cBR, cBL, cLeft, cRight, cTop, cBottom, cClear, lClear, nRet, nSpin
cUL := substr(cFrame,1,1) && Upper Left Of Box
cUR := substr(cFrame,3,1) && Upper Right Of Box
cBR := substr(cFrame,5,1) && Bottom Right Of Box
cBL := substr(cFrame,7,1) && Bottom Left Of Box
cLeft := substr(cFrame,4,1) && Left Of Box
cRight := substr(cFrame,8,1) && Right Of Box
cTop := substr(cFrame,2,1) && Top Of Box
cBottom := substr(cFrame,6,1) && Bottom Of Box
cClear := space(1) && Clear chr()
lClear := .f. && Check if cClear passed
if len(cFrame) == 9
cClear := substr(cFrame,9,1)
lClear := .t.
endif
nLines := nRow2-nRow1
nWidth := (nCol2-nCol1)-1
nRet := SWASay(nPort,nRow1,nCol1,cUL+replicate(cTop,nWidth)+cUR)
for nLoop := 1 to nLines -1
nRet := SWASay(nPort,nRow1+nLoop,nCol1,cLeft)
if lClear
nRet := SWASay(nPort,nRow1+nLoop,nCol1+1,replicate(cClear,nWidth))
endif
nRet := SWASay(nPort,nRow1+nLoop,nCol2,cRight)
next
nRet := SWASay(nPort,nRow2,nCol1,cBL+replicate(cBottom,nWidth)+cBR)
RETURN(0)
***********************************************************************
**
** Function: SWAPROMPT()
**
** Called by: SWMAINMENU()
** : SWTRANSMENU()
**
** Calls: SWFLUSHRX()
** : SWACOLOR()
** : SWASAY()
** : SWAPOSCUR()
** : SWGETCD()
** : SWRXEMPTY()
** : SWPEEKCHR()
** : SWWTRXCNT()
** : SWRXBUFFER()
** : SWRXCHAR()
** : SWAERSLINE()
**
** This is an ANSI light bar menu prompt function.
**
** nPort = COM port in use.
** aPromptArray = 2 dim array/table containing prompt parameters.
** ie: { {nRow,nCol,cPrompt,cMessage};
** {nRow,nCol,cPrompt,cMessage} }
** nMessageRow = Row for cMessage.
** nMesageCol = Column for cMessage.
** nFColor = cPrompt foreground color.
** nBColor = cPrompt background color.
** nFHighLight = cPrompt high-lighted foreground color.
** nBHighLight = cPrompt high-lighted background color.
** nElements = Number of prompts.
**
***********************************************************************
FUNCTION SWAPrompt(nPort,aPromptArray,nMessageRow,nMesageCol,nFColor,nBColor,nFHighLight,nBHighLight,nElements)
LOCAL nLoop, nRet, nKey, nPrev, nExitVal, nSpin, cPrompt, nMaxMessage
nRet := SWFlushRX(nPort)
nMaxMessage := 0
for nLoop := 1 to nElements
nRet := SWAColor(nPort,nFColor,nBColor)
nRet := SWASay(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2],aPromptArray[nLoop,3])
nMaxMessage := iif(len(aPromptArray[nLoop,4])>nMaxMessage,len(aPromptArray[nLoop,4]),nMaxMessage)
next
nLoop := 1
nExitVal := 0
do while .t.
nRet := SWAColor(nPort,nFHighLight,nBHighLight)
nRet := SWASay(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2],aPromptArray[nLoop,3])
nRet := SWAColor(nPort,nFColor,nBColor)
nRet := SWAPosCur(nPort,nMessageRow,nMesageCol)
nRet := SWASay(nPort,nMessageRow,nMesageCol,replicate(" ",nMaxMessage))
nRet := SWASay(nPort,nMessageRow,nMesageCol,aPromptArray[nLoop,4])
nRet := SWAPosCur(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2])
cPrompt := ""
do while .t. && Parse key strokes
if !SWGetCD(nPort)
nKey := SWCNOCARRIER
exit
endif
nRet := inkey()
if lastkey() == 27
nKey := SWCLOCALABORT
exit
endif
if !SWRXEmpty(nPort)
if SWPeekChr(nPort,0) != 13
nRet := SWWtRXCnt(nPort,3*SWSECOND,3)
do case
case nRet == SWCSUCCESSFUL
nRet := SWRXBuffer(nPort,@cPrompt,3,-1,@nKey)
nKey := asc(substr(cPrompt,3,1))
exit
case nRet == SWCTIMEDOUT
nKey := SWPeekChr(nPort,0)
if nKey == 13
exit
endif
otherwise
loop
endcase
else
nKey := SWRXChar(nPort)
exit
endif
endif
enddo
nRet := SWFlushRX(nPort)
do case
case nKey == 65 .or. nKey == 68 && Uparrow, Ctrl-E
nPrev := nLoop
nLoop := nLoop - 1
nLoop := iif(nLoop=0,nElements,nLoop)
case nKey == 66 .or. nKey == 67 && Dnarrow, Ctrl-X
nPrev := nLoop
nLoop := nLoop + 1
nLoop := iif(nLoop>nElements,1,nLoop)
case nKey == 72 && Home, Ctrl-A
nPrev := nLoop
nLoop := 1
case nKey == 75 && End, Ctrl-F
nPrev := nLoop
nLoop := nElements
case nKey == 13 && Enter, Ctrl-M
nExitVal := nLoop
exit
case nKey == SWCNOCARRIER
nExitVal := SWCNOCARRIER
exit
case nKey == SWCLOCALABORT
nExitVal := SWCLOCALABORT
exit
otherwise
nExitVal := 0
for nSpin := 1 to nElements
if upper(substr(aPromptArray[nSpin,3],1,1)) == upper(chr(nKey))
nExitVal := nSpin
nSpin := nElements + 1
endif
next
if nExitVal == 0
loop
else
nPrev := nLoop
nLoop := nExitVal
nRet := SWAColor(nPort,nFHighLight,nBHighLight)
nRet := SWASay(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2],aPromptArray[nLoop,3])
nRet := SWAColor(nPort,nFColor,nBColor)
nRet := SWAPosCur(nPort,nMessageRow,nMesageCol)
nRet := SWAErsLine(nPort)
nRet := SWASay(nPort,nMessageRow,nMesageCol,aPromptArray[nLoop,4])
nRet := SWASay(nPort,aPromptArray[nPrev,1],aPromptArray[nPrev,2],aPromptArray[nPrev,3])
exit
endif
endcase
nRet := SWAColor(nPort,nFColor,nBColor)
nRet := SWASay(nPort,aPromptArray[nPrev,1],aPromptArray[nPrev,2],aPromptArray[nPrev,3])
enddo
RETURN(nExitVal)
** EOF: EZBBSC.PRG